//
//  JsBridge.h
//  SHNet
//
//  Created by FranklinPhill on 16/1/7.
//  Copyright © 2016年 Fire. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "WebViewJavascriptBridge.h"

typedef void (^JsHandler)(id data);

@class JsBridge;

@protocol WebViewApiDelegate <NSObject>

@required

- (void)invoke:(JsBridge *)bridge api:(NSString *)api callback:(WVJBResponseCallback)callback withArgs:(NSDictionary *)args reqCode:(NSNumber *)code;

- (NSArray *)getWebApiNames;

@end

@interface JsBridge : NSObject

- (id)initWithWebView:(UIWebView *)webView withDelegate:(id<UIWebViewDelegate>) delegate;

- (void)addWebViewApi:(id<WebViewApiDelegate>)webViewApi;

- (void)callback:(WVJBResponseCallback)responseCallback withReqCode:(NSNumber *)code withResult:(NSObject *)object;

- (void)jsInvoke:(NSString *)api args:(NSDictionary *)args handler:(JsHandler)handler;

- (void)releaseJsBridge;

@end
